package com.kkb.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.mapper.HospitalizationMapper;
import com.kkb.pojo.Hospitalization;
import com.kkb.vo.HospitalizationQueryVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HospitalizationService {
    @Resource
    HospitalizationMapper hospitalizationMapper;

    public PageInfo queryAll(int index, int size, HospitalizationQueryVO hospitalizationQueryVO) {
        hospitalizationQueryVO.trim();
        PageHelper.startPage(index, size);
        List<Hospitalization> result = hospitalizationMapper.selectByVague(hospitalizationQueryVO);
        PageInfo pageInfo = new PageInfo(result);
        return pageInfo;
    }

    public int add(Hospitalization hospitalization) {
        return hospitalizationMapper.insert(hospitalization);
    }

    public int exitHospital(List<Integer> patients){
        return hospitalizationMapper.exitHospital(patients);
    }

    public int outHospital(List<Integer> patients){
        return hospitalizationMapper.outHospital(patients);
    }

    public Hospitalization queryById(int id) {
        return hospitalizationMapper.selectByPrimaryKey(id);
    }

    public int update(Hospitalization hos) {
        return hospitalizationMapper.updateByPrimaryKeySelective(hos);
    }
}
